"""7.3 文件读写练习
--- 我的学习笔记 ---
1、Python很有趣
2、文件操作很简单
"""
#写入新文件
with open('practise.txt', 'w',encoding="utf8") as file:
    file.write("--- 我的学习笔记 ---\n")
    file.write("1、Python很有趣\n")
    file.write("2、文件操作很简单\n")

#读取practise.txt文件
print("【第一读取文件内容】")
with open('practise.txt', 'r',encoding="utf8") as file:
    print(file.read())

#追加笔记
with open('practise.txt', 'a',encoding="utf8") as file:
    line=input("请输入笔记：")
    file.write(line+"\n")

#再读取practise.txt文件的内容
print("【第二读取文件内容】")
with open('practise.txt', 'r',encoding="utf8") as file:
    print(file.read())